<template>
<div>
  <h1>新闻</h1>
  <table border="1" cellspacing="1" align="center">
    <tr>
      <td>新闻</td>
      <td>操作</td>
    </tr>
    <tr v-for="i in ffo">
      <td>{{i.name}}</td>
      <td>
        <button @click="get_xq(i.id)">查看</button>
      </td>
    </tr>
  </table>
  <button @click="get_new(i)" v-for="i in num">{{i}}</button>
</div>
</template>

<script>
export default {
  name: "lxx",
  data(){
    return{
      ffo:[],
      num:'',
      userid:localStorage.getItem('userid')
    }
  },
  methods:{
    get_new(i){
      this.$axios.get('users/NewAPI/?cpage='+i)
      .then(res=>{
        this.ffo = res.data.list
        this.num = res.data.num
      })
    },
    get_xq(id){
      if(this.userid){
        this.$router.push({path:'/news_xq',query:{'id':id}})
      }
     else {
       alert('未登录')
        this.$router.push('/denglu')
      }
    }
  },
  mounted() {
    this.get_new(1)
    // localStorage.setItem('userid','')
  }
}
</script>

<style scoped>

</style>
